Remove Nginx configs and Let’s Encrypt Certificates
1. Stop Nginx:
It’s recommended to stop Nginx before making any configuration changes. Use the following command (replace ‘your_user’ with your actual username if needed):
sudo systemctl stop nginx
2. Remove Nginx Configuration:
- Identify the configuration file for your static page:
- Look for files named after your domain (e.g.,
yourdomain.conf
) in the/etc/nginx/sites-available
directory.
- Look for files named after your domain (e.g.,
- Remove the configuration file(s):
sudo rm /etc/nginx/sites-available/yourdomain.conf
- Check for a symbolic link in the
sites-enabled
directory pointing to the removed configuration file:
ls -l /etc/nginx/sites-enabled/yourdomain.conf
- If a symbolic link exists, remove it:
sudo rm /etc/nginx/sites-enabled/yourdomain.conf
3. Remove Let’s Encrypt Certificates:
- List all certificates using the
certbot certificates
command. Identify the certificates for your domain. - Remove the certificates using
certbot delete
:
sudo certbot delete --cert-name yourdomain.com
4. Verify and Restart Nginx:
- Test the Nginx configuration for syntax errors:
sudo nginx -t
- If the test is successful, restart Nginx:
sudo systemctl start nginx
Important Note:
- Double-check the domain name before removing the certificates.
- Make sure you don’t need the static page anymore before removing the configuration.